{template '_header'}

<div class="page-header">

    当前位置：<span class="text-primary">{if !empty($item['id'])}编辑{else}添加{/if}门店{if !empty($item['id'])}({$item['storename']}){/if}</span>
</div>

<div class="page-content">
    {ifp 'shop.verify.store.add'}
    <div class="page-sub-toolbar">
        <span class=''>
            <a class="btn btn-primary btn-sm" href="{php echo webUrl('shop/verify/store/add')}">添加新门店</a>
	</span>
        {/if}
    </div>
    <form {ife 'shop.verify.store' $item}action="" method="post"{/if} class="form-horizontal form-validate" enctype="multipart/form-data">
        <input type="hidden" name="id" value="{$item['id']}" />
        <div class="form-group">
            <label class="col-lg control-label must">门店名称</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.verify.store' $item}
                    <input type="text" name="storename" class="form-control" value="{$item['storename']}" data-rule-required="true"/>
                {else}
                    <div class='form-control-static'>{$item['storename']}</div>
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label">门店LOGO</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.verify.store' $item}
                    {php echo tpl_form_field_image2('logo',$item['logo'])}
                {else}
                    {if !empty($item['logo'])}
                        <a href='{php echo tomedia($item[' logo'])}' target='_blank'>
                            <img src="{php echo tomedia($item['logo'])}" style='width:100px;border:1px solid #ccc;padding:1px'/>
                        </a>
                    {/if}
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label">门店地址</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.verify.store' $item}
                    <input type="text" name="address" class="form-control" value="{$item['address']}"/>
                {else}
                    <div class='form-control-static'>{$item['address']}</div>
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label">门店电话</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.verify.store' $item}
                    <input type="text" name="tel" class="form-control" value="{$item['tel']}"/>
                {else}
                    <div class='form-control-static'>{$item['tel']}</div>
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label">营业时间</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.verify.store' $item}
                    <input type="text" name="saletime" class="form-control" value="{$item['saletime']}"/>
                {else}
                    <div class='form-control-static'>{$item['saletime']}</div>
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label">门店位置</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.verify.store' $item}
                    {php echo tpl_form_field_coordinate('map',array('lng'=>$item['lng'],'lat'=>$item['lat']))}
                {else}
                    <div class='form-control-static'>lng={$item['lng']},lat={$item['lat']}</div>
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label">门店支持</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.verify.store' $item}
                <label class='radio-inline'><input type='radio' name='type' value='1' {if $item['type']==1}checked{/if} /> 支持自提</label>
                <label class='radio-inline'><input type='radio' name='type' value='2' {if $item['type']==2}checked{/if} /> 支持核销</label>
                <label class='radio-inline'><input type='radio' name='type' value='3' {if $item['type']==3}checked{/if} /> 支持自提+核销</label>
                {else}
                    <div class='form-control-static'>{if $item['type']==1}支持自提{else if $item['type']==2}支持核销{else if$item['type']==3}支持自提+核销{/if}</div>
                {/if}
            </div>
        </div>

        <div class="form-group" id="pick_info" {if empty($item['type']) || $item['type']==2}style="display:none;"{/if}>
            <label class="col-lg control-label">自提信息</label>
            <div class="col-sm-10 col-xs-12">
                {ife 'shop.verify.store' $item}
                    <label class="radio-inline" style="float: left;padding-left:0px;">联系人</label>
                    <div class="col-sm-9 col-xs-12" style="width: 120px; float: left; margin: 0px 20px 0px -5px;">
                        <input type="text" value="{$item['realname']}" class="form-control" name="realname" style="width:120px;padding:5px;">
                    </div>
                    <label class="radio-inline" style="float: left;">联系电话</label>
                    <div class="col-sm-9 col-xs-12" style="width: 120px; float: left; margin: 0px 20px 0px -5px;">
                        <input type="text" value="{$item['mobile']}" class="form-control" name="mobile" style="width:120px;padding:5px;">
                    </div>
                    <label class="radio-inline" style="float: left;">自提时间</label>
                    <div class="col-sm-9 col-xs-12" style="width: 200px; float: left; margin: 0px 0px 0px -5px;">
                        <input type="text" value="{$item['fetchtime']}" class="form-control" name="fetchtime" style="width:200px;padding:5px;">
                    </div>
                {else}
                    <div class='form-control-static'>联系人:{$item['realname']} 联系电话:{$item['mobile']}</div>
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label">门店简介</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.verify.store' $item}
                    <textarea name="desc" class="form-control richtext"rows="5">{$item['desc']}</textarea>
                {else}
                    <div class='form-control-static'>{$item['desc']}</div>
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label">状态</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.verify.store' $item}
                    <label class='radio-inline'><input type='radio' name='status' value=1' {if $item['status']==1}checked{/if} /> 启用</label>
                    <label class='radio-inline'><input type='radio' name='status' value=0' {if $item['status']==0}checked{/if} /> 禁用</label>
                {else}
                    <div class='form-control-static'>{if $item['status']==1}启用{else}禁用{/if}</div>
                {/if}
            </div>
        </div>

        {if $printer}
            <div class="form-group">
                <label class="col-lg control-label">选择订单打印机</label>
                <div class="col-sm-9 col-xs-12">
                    {ifp 'sysset.printer.set'}
                        <?php echo tpl_selector('order_printer',array(
                            'preview'=>true,
                            'readonly'=>true,
                            'nokeywords'=>true,
                            'multi'=>1,
                            'value'=>$item['title'],
                            'url'=>webUrl('sysset/printer/printer_query'),
                            'items'=>$order_printer_array,
                            'buttontext'=>'选择商品',
                            'placeholder'=>'请选择商品')
                            )?>
                    {else}
                        <div class="input-group multi-img-details container ui-sortable">
                            {loop $order_printer_array $it}
                                <div data-name="goodsid" data-id="{$it['id']}" class="multi-item">
                                    <img src="{php echo tomedia($it['thumb'])}" class="img-responsive img-thumbnail">
                                    <div class="img-nickname">{$it['title']}</div>
                                </div>
                            {/loop}
                        </div>
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg control-label">选择订单打印模板</label>
                <div class="col-sm-9 col-xs-12">
                    {ifp 'sysset.printer.set'}
                        <select class='form-control' name='order_template'>
                            <option >选择您需要的订单打印模板</option>
                            {loop $order_template $value}
                            <option value="{$value['id']}" {if $value['id']==$item['order_template']}selected{/if}>{$value['title']}</option>
                            {/loop}
                        </select>
                    {else}
                        <div class='form-control-static'>
                            {if empty($item['order_template'])}选择您需要的订单打印模板{else}{$item['order_template']}{/if}
                        </div>
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg control-label">订单打印方式</label>
                <div class="col-sm-9 col-xs-12">
                    {ifp 'sysset.notice.edit'}
                        <label class="checkbox-inline"><input type="checkbox" value="1" name='ordertype[]' {if in_array('1',$ordertype)}checked{/if} /> 下单打印</label>
                        <label class="checkbox-inline"><input type="checkbox" value="2" name='ordertype[]' {if in_array('2',$ordertype)}checked{/if} /> 付款打印</label>
                        <label class="checkbox-inline"><input type="checkbox" value="3" name='ordertype[]' {if in_array('3',$ordertype)}checked{/if} /> 确认收货打印</label>
                        <div class="help-block">通知商家方式</div>
                    {else}
                        <input type="hidden" name="data[ordertype]" value="{$data['ordertype']}" />
                        <div class='form-control-static'>{if in_array('1',$ordertype)}下单打印;{/if}{if in_array('2',$ordertype)}付款打印;{/if}{if in_array('3',$ordertype)}确认收货打印;{/if}</div>
                    {/if}
                </div>
            </div>
        {/if}
        <div class="form-group"></div>
        <div class="form-group">
            <label class="col-lg control-label"></label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.verify.store' $item}
                    <input type="submit" value="提交" class="btn btn-primary"  />
                {/if}
                <input type="button" name="back" onclick='history.back()' {ifp 'shop.verify.store.add|shop.verify.store.edit'}style='margin-left:10px;'{/if} value="返回列表" class="btn btn-default" />
            </div>
        </div>
    </form>
</div>

<script language='javascript'>
    $(function () {
        $(':radio[name=type]').click(function () {
            type = $("input[name='type']:checked").val();

            if(type=='1' || type=='3'){
                $('#pick_info').show();
            } else {
                $('#pick_info').hide();
            }
        })
    })
</script>
{template '_footer'}